<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <input type="text" class="text">
  <button class="btn">猜数字</button>
  <script>
    var oText = document.querySelector(".text");
    var oBtn = document.querySelector(".btn");
    var target = Math.floor(Math.random()*101);
    oBtn.onclick = function(){
      var num = Number(oText.value);
      if(num>target){
        alert("大于结果")
      }else if(num<target){
        alert("小于结果")
      }else if(num == target){
        alert("回答正确");
        target = Math.floor(Math.random()*101);
      }
    }
    
  </script>
</body>
</html>